import numpy as np
import pandas as pd

ages = np.array([1, 5, 10, 40, 36, 12, 58, 62, 77, 89, 100, 18, 20, 25, 30, 32])  # 年龄数据
# pd.cut：第一个参数是一个ndarray数组；第二个参数是分隔点，第三个参数是每个区间对应的标签
cut = pd.cut(ages, [0, 5, 20, 30, 50, 100], labels=[u"婴儿", u"青年", u"中年", u"壮年", u"老年"])
print(cut)